import React from 'react';
import {connect} from 'dva';
import {withRouter} from 'dva/router';
import {Layout} from '../../../components';
import {filterText} from '../../../utils/content';
import { Table, Badge, Menu, Dropdown, Icon,Button,Modal,message} from 'antd';
const {Notice,InputItem,List,Tab} = Layout;
const confirm = Modal.confirm;

function startConfirm() {
    confirm({
      title: '确定要启用该渠道吗？',
      centered:true,
    //   className:'confirm',
      onOk() {
        console.log('OK');
      },
      onCancel() {
        console.log('Cancel');
      },
    });
}
function stopConfirm() {
    confirm({
      title: '确定要停用该渠道吗？',
      centered:true,
    //   className:'confirm',
      onOk() {
        console.log('OK');
      },
      onCancel() {
        console.log('Cancel');
      },
    });
}

const tableHeadAction={
    btn:  <Button onClick={()=>{message.info('This is a normal message');}}>订单导出</Button>
}

// 保存搜索区域值
function saveData(allData){
  console.log(allData);
  return allData
}
// 搜索区域title以及类型
const searchLabel = [{
  title: '下单日期',
  type: 'calendarRange',
}, {
  title: '采购客户',
}, {
  title: '订单编号',
}]
const noticeText=<div className='fl'>如需查询2018年11月1日之前订单请<a href="javascript:;">点击这里</a>进入查询！</div>
function OrderList({children, orderList , dispatch, location, history}) {
  console.log(orderList);
  
  const {searchLabelData,list}=orderList
  const dataProps={
      searchLabelData,
      saveData
  }
  const listProps={
    list,
    tableHead:[{
      title:'商品',
      key:['productProperty'],
      width:'25%'
    },{
      title:'单价',
      key:['price'],
      width:'10%'
    },{
      title:'数量/重量',
      key:['number','weight'],
      unit:['件','吨'],
      width:'15%'
    },{
      title:'应付总金额',
      key:['total'],
      width:'10%'
    },{
      title:'买家',
      key:['name','company'],
      width:'20%'
    },{
      title:'状态',
      key:['orderState'],
      width:'10%'
    },{
      title:'操作',
      key:['action'],
      width:'10%'
    }]
  }
  const tabProps={
    tabContent:[{
      num:20,
      title:'全部',
      content: <List {...listProps}/>
    },{
      num:20,
      title:'待接单',
      content: <List {...listProps}/>
  },{
    num:20,
    title:'交易中',
    content: <List {...listProps}/>
  },{
    num:20,
    title:'已完成',
    content: <List {...listProps}/>
  },{
    num:20,
    title:'已关闭',
    content: <List {...listProps}/>
  }]
}
return(
      <div>
        <Notice title={noticeText}/>
        <div className="clear search">
            {
                searchLabel.map((item,index)=>{
                    return(
                        <InputItem {...item} {...searchLabelData[index]} {...dataProps} order={index}  key={index} filterProps={['saveData','filterProps','searchLabelData','order','title','label']}/>
                    )
                })
            }
            <Button type="primary" className="btn-search" onClick={saveData}>搜索</Button>
        </div>
        <Tab {...tabProps}/>
      </div>
  )
}



export default withRouter(connect(({orderList }) => ({orderList }))(OrderList));
